package lab04;
import java.util.Scanner;

public class Hanoi {

    private static int counter = 0;

    // recursive call
    // n:圆盘数量 src 从哪开始 with 利用哪个 desc 移动到娜
    private static void resolve(int n, String src, String with, String desc) {
        if (n == 1) {
            System.out.println(src + " -> " + desc);
            counter++;
        } else {
            resolve(n - 1, src, desc, with);
            System.out.println(src + " -> " + desc);
            counter++;
            resolve(n - 1, with, src, desc);
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("input n: ");
        int n = scanner.nextInt();
        resolve(n, "A", "B", "C");
        System.out.println(counter);
    }
}